#include "observer_pattern.h"

struct A {
    int a, b;
    void print(int a, int b) {
        std::cout << a << " " << b << std::endl;
    }
};

void print(int a, int b) {
    std::cout << a << " " << b << std::endl;
}

int observer() {
    Events<std::function<void(int, int)>> event;

    auto key1 = event.connect(print);

    A obj;
    auto key2 = event.connect([&obj](int a, int b){
        obj.a = a;
        obj.b = b;
    });

    std::function<void(int, int)> f = std::bind(&A::print, &obj, 
                        std::placeholders::_1, std::placeholders::_2);
    auto key3 = event.connect(f);

    int a = 1, b = 3;
    event.notify(a, b);
    event.disconnectAll();

    return 0;
}